package com.fit.beans;

import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import com.fit.interfaces.Customer;
import com.fit.interfaces.Jewelry;
import com.fit.interfaces.Otkup;
import com.fit.interfaces.Salesman;
import com.fit.service.BuyUniqueID;
import com.fit.service.OtkupUniqueId;
import com.fit.service.Otkupi;

public class OtkupBean implements Otkup{
	public String id;
	public Date datumOtkupa;
	public int cijenaOtkupa;
	public Customer customer;
	public Salesman salesman;
	public List<Jewelry> jewelry;
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public Date getDatumOtkupa() {
		return datumOtkupa;
	}
	public void setDatumOtkupa(Date datumOtkupa) {
		this.datumOtkupa = datumOtkupa;
	}
	public int getCijenaOtkupa() {
		return cijenaOtkupa;
	}
	public void setCijenaOtkupa(int cijenaOtkupa) {
		this.cijenaOtkupa = cijenaOtkupa;
	}
	public Customer getCustomer() {
		return customer;
	}
	public void setCustomer(Customer customer) {
		this.customer = customer;
	}
	public Salesman getSalesman() {
		return salesman;
	}
	public void setSalesman(Salesman salesman) {
		this.salesman = salesman;
	}
	public List<Jewelry> getJewelry() {
		return jewelry;
	}
	public void setJewelry(List<Jewelry> jewelry) {
		this.jewelry = jewelry;
	}
//	public int setCijenaOtkupa() {
//		// TODO Auto-generated method stub
//		return 0;
//	}
	public void executeOtkupCreation(Salesman salesman, Customer customer,Jewelry jewelry,
			Otkupi otkupi){
		
		this.setId(OtkupUniqueId.getOtkupUniqueID());
		this.setSalesman(salesman);
		this.setCustomer(customer);
		
		List<Jewelry> l = new LinkedList<Jewelry>();
		l.add(jewelry);
		
		this.setJewelry(l);
				
		customer.getOtkup().add(this);
		jewelry.getOtkup().add(this);
		salesman.getOtkup().add(this);
		
		otkupi.save(this);
	}
	
	}
	
	

